import requests

__author__ = 'yangxianming'

def get_data(key):
    url = "http://test.e-fuli.cn/configuration/dataManager"
    # return_data = return_data.encode('utf-8')
    if key == "":
        params = {"action":"getData"}
        r = requests.post(url, data=str(params).encode('utf-8'))
        # if r.status_code != 200:
        #     raise CustomError("no 200")
        arr = r.json()["result"]
        re_json = {}
        for one in arr:
            re_json[one[2]] = one[3]
        return re_json
    else:
        params = {"action":"getData","key":key}
        r = requests.post(url, data=str(params).encode('utf-8'))
        # if r.status_code != 200:
        #    raise CustomError("no 200")
        return r.json()["result"]